/*  1:   */ package org.intellij.images.fileTypes;
/*  2:   */ 
/*  3:   */

import com.intellij.lang.documentation.AbstractDocumentationProvider;
import com.intellij.openapi.project.DumbService;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileWithId;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFileSystemItem;
import com.intellij.util.indexing.FileBasedIndex.ValueProcessor;
import org.intellij.images.index.ImageInfoIndex;
import org.jetbrains.annotations.Nullable;

import java.net.URI;
import java.net.URISyntaxException;

/*  4:   */
/*  5:   */
/*  6:   */
/*  7:   */
/*  8:   */
/*  9:   */
/* 10:   */
/* 11:   */
/* 12:   */
/* 13:   */
/* 14:   */
/* 15:   */
/* 16:   */ 
/* 17:   */ public class ImageDocumentationProvider
/* 18:   */   extends AbstractDocumentationProvider
/* 19:   */ {
/* 20:   */   private static final int a = 300;
/* 21:   */   
/* 22:   */   public String generateDoc(PsiElement paramPsiElement1, @Nullable PsiElement paramPsiElement2)
/* 23:   */   {
/* 24:40 */     final String[] arrayOfString = { null };
/* 25:42 */     if (((paramPsiElement1 instanceof PsiFileSystemItem)) && (!((PsiFileSystemItem)paramPsiElement1).isDirectory()))
/* 26:   */     {
/* 27:43 */       VirtualFile localVirtualFile = ((PsiFileSystemItem)paramPsiElement1).getVirtualFile();
/* 28:44 */       if (((localVirtualFile instanceof VirtualFileWithId)) && (!DumbService.isDumb(paramPsiElement1.getProject()))) {
/* 29:45 */         ImageInfoIndex.processValues(localVirtualFile, new FileBasedIndex.ValueProcessor()
/* 30:   */         {
/* 31:   */           public boolean process(VirtualFile paramAnonymousVirtualFile, ImageInfoIndex.ImageInfo paramAnonymousImageInfo)
/* 32:   */           {
/* 33:48 */             int i = paramAnonymousImageInfo.width;
/* 34:49 */             int j = paramAnonymousImageInfo.height;
/* 35:   */             
/* 36:51 */             int k = Math.max(paramAnonymousImageInfo.width, paramAnonymousImageInfo.height);
/* 37:52 */             if (k > 300)
/* 38:   */             {
/* 39:53 */               double d = 300.0D / k;
/* 40:54 */               i = (int)(i * d);
/* 41:55 */               j = (int)(j * d);
/* 42:   */             }
/* 43:   */             try
/* 44:   */             {
/* 45:58 */               String str1 = paramAnonymousVirtualFile.getPath();
/* 46:59 */               if (SystemInfo.isWindows) {
/* 47:60 */                 str1 = "/" + str1;
/* 48:   */               }
/* 49:62 */               String str2 = new URI("file", null, str1, null).toString();
/* 50:63 */               arrayOfString[0] = String.format("<html><body><img src=\"%s\" width=\"%s\" height=\"%s\"><p>%sx%s, %sbpp</p><body></html>", new Object[] { str2, Integer.valueOf(i), Integer.valueOf(j), Integer.valueOf(paramAnonymousImageInfo.width), Integer.valueOf(paramAnonymousImageInfo.height), Integer.valueOf(paramAnonymousImageInfo.bpp) });
/* 51:   */             }
/* 52:   */             catch (URISyntaxException localURISyntaxException) {}
/* 53:69 */             return true;
/* 54:   */           }
/* 55:69 */         }, paramPsiElement1.getProject());
/* 56:   */       }
/* 57:   */     }
/* 58:75 */     return arrayOfString[0];
/* 59:   */   }
/* 60:   */ }



/* Location:           E:\idea\

 * Qualified Name:     org.intellij.images.fileTypes.ImageDocumentationProvider

 * JD-Core Version:    0.7.0.1

 */